<template>

  <item-title title="基本信息" />

  <el-form v-if="agent.agentType === 'agent'" :inline="true" label-position="right" label-width="140px" size="small" class="filter-form-inline">
    <el-row style="margin-left: 0px;margin-right:0px;">
      <el-col :span="12">
        <el-form-item label="代理商编号：" style="width: 100%;">
          <span>{{ agent.agentNumber }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="代理商状态：" style="width: 100%;">
          <span v-if="agent.tradeStatus == 1">正式代理商</span>
          <span v-else>准代理商</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="所在地区：" style="width: 100%;">
          <span>{{ agent.provinceName }}/{{ agent.cityName }}/{{ agent.areaName }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="详细地址：" style="width: 100%;">
          <span>{{ agent.address }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="统一社会信用代码：" style="width: 100%;">
          <span>{{ agent.creditCode }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="联系人：" style="width: 100%;">
          <span>{{ agent.userName }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="联系电话：" style="width: 100%;">
          <span>{{ agent.tel }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="创建人：" style="width: 100%;">
          <span>{{ agent.creatorName }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="创建时间：" style="width: 100%;">
          <span>{{ dateFormat('yyyy-mm-dd',agent.createdAt) }}</span>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>

  <el-form v-else :inline="true" label-position="right" label-width="100px" size="small" class="filter-form-inline">
    <el-row style="margin-left: 0px;margin-right:0px;">
      <el-col :span="12">
        <el-form-item label="兼职编号：" style="width: 100%;">
          <span>{{ agent.agentNumber }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="兼职状态：" style="width: 100%;">
         <span>{{ getLabel('agent_status_person',agent?.agentStatus) }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="详细地址：" style="width: 100%;">
          <span>{{ agent.address }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="性别：" style="width: 100%;">
          <span>{{ agent.sex === '1' ? '男' : '女' }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="联系电话：" style="width: 100%;">
          <span>{{ agent.tel }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="身份证号：" style="width: 100%;">
          <span>{{ agent.cardNumber }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="创建人：" style="width: 100%;">
          <span>{{ agent.creatorName }}</span>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="创建时间：" style="width: 100%;">
          <span>{{ dateFormat('yyyy-mm-dd',agent.createdAt) }}</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row style="margin-left: 0px;margin-right:0px;">
      <el-col :span="24">
        <el-form-item label="附件：" style="width: 100%;">
          <filesUploadView ref="refFile" :list="agent.cardFiles" disabled />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>

  <item-title title="修改记录" />

  <operation-view v-if="agent.agentType" :id="agent.id" mode="agent" />

</template>

<script>
import {defineComponent, inject, onMounted, reactive, toRefs} from 'vue'

export default defineComponent({
  name: 'AgentInfo',
  props: {
    id: {
      type: Number,
      default: 0
    }
  },
  setup(props, { emit }) {
    const api = inject('api')
    var data = reactive({
      agent: {}
    })

    onMounted(() => {
      api.channelAgent.POTENTIALAGENT_DETAIL(props.id).then(res => {
        if (!res.code && res.data) {
          data.agent = res.data.data
        }
      })
    })

    return {
      ...toRefs(data)
    }
  }
})
</script>

<style scoped>

</style>
